﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lumberjack.BusinessLogic
{
    public sealed class RulesRepository
    {
        private static IRepository<Rule> _ruleService;
        private static IRepository<Rule_b> _ruleBService;
        private static IRepository<Rule_n> _ruleNService;
        private static IRepository<Rule_r> _ruleRService;

        private static List<Rule_r> _ruleR;
        private static List<Rule_b> _ruleB;
        private static List<Rule_n> _ruleN;
        private static List<Rule> _rule;

        static RulesRepository()
        {
            _ruleService = new RepositoryService<Rule>(MainWindow.context);
            _ruleBService = new RepositoryService<Rule_b>(MainWindow.context);
            _ruleNService = new RepositoryService<Rule_n>(MainWindow.context);
            _ruleRService = new RepositoryService<Rule_r>(MainWindow.context);
        }

        public static List<Rule_b> ruleB
        {
            get
            {
                if(_ruleB == null)
                {
                    _ruleB = _ruleBService.GetAll().ToList();
                }
                return _ruleB;
            }
            
        }
        public static List<Rule_n> ruleN
        {
            get
            {
                if (_ruleN == null)
                {
                    _ruleN = _ruleNService.GetAll().ToList();
                }
                return _ruleN;
            }
        }

        public static List<Rule_r> ruleR
        {
            get
            {
                if (_ruleR == null)
                {
                    _ruleR = _ruleRService.GetAll().ToList();
                }
                return _ruleR;
            }
        }

        public static List<Rule> rule
        {
            get
            {
                if (_rule == null)
                {
                    _rule = _ruleService.GetAll().ToList();
                }
                return _rule;
            }
        }
    }
}
